package com.zoweunion.mechanic.util.task;

import com.alibaba.fastjson.JSON;
import com.zoweunion.mechanic.dao.TSSsUserMapper;
import com.zoweunion.mechanic.dao.app.*;
import com.zoweunion.mechanic.dao.base.MessageRecordDao;
import com.zoweunion.mechanic.dao.base.UserDao;
import com.zoweunion.mechanic.dao.order.CGOrderDao;
import com.zoweunion.mechanic.dao.shangji.ShangJiDao;
import com.zoweunion.mechanic.dao.shangji.ShangJiMapper;
import com.zoweunion.mechanic.entity.vo.TSSsUserVO;
import com.zoweunion.mechanic.model.User;
import com.zoweunion.mechanic.model.things.ThingsData;
import com.zoweunion.mechanic.service.app.TSSsHumanfaceService;
import com.zoweunion.mechanic.service.base.BaseService;
import com.zoweunion.mechanic.service.impl.TSSsUserServiceImpl;
import com.zoweunion.mechanic.util.DateUtil;
import com.zoweunion.mechanic.util.JiGuangPushUtil;
import com.zoweunion.mechanic.util.UuidUtil;
import com.zoweunion.mechanic.util.common.CarDataStatisticsUtil;
import com.zoweunion.mechanic.util.constants.Constants;
import com.zoweunion.mechanic.util.constants.PushConstants;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.text.StrBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;

/**
 * app推送任务
 */
@Component
public class PushTask extends BaseService {
    private Logger logger = LoggerFactory.getLogger(PushTask.class);

    @Autowired
    private TSSsUserServiceImpl tsSsUserService;
    @Autowired
    private ToolViewBoardMapper toolViewBoardMapper;
    @Autowired
    private ToolCarDataMapper toolCarDataMapper;
    @Autowired
    private ShangJiMapper shangJiMapper;
    @Autowired
    private UserDao userDao;
    @Autowired
    private TSSsUserMapper userMapper;
    @Autowired
    private OrderDao orderDao;
    @Autowired
    private PushMessageRecordMapper pushMessageRecordMapper;
    @Autowired
    private MessageRecordDao messageRecordDao;
    @Autowired
    private JiGuangPushUtil jiGuangPushUtil;
    @Autowired
    private CGOrderDao cGOrderDao;

    @Autowired
    private TSSsHumanfaceService tSSsHumanfaceService;

    @Autowired
    private TSSsHumanfaceDao tSSsHumanfaceDao;

    @Autowired
    private ShangJiDao shangJiDao;

    @Autowired
    private AppDao appDao;

    /**
     * 通知栏/消息栏
     * 创建app推送工单统计信息
     */
    // @Scheduled(cron = "0 0 20 * * ? ")
    public void createPushOrderInfo() {
        String contentTemplate = "今日工单速报 " +
                "截止到今日%s点，共有待服务%s单，待回款%s单，待支付%s单，查看详情 >>>";

        LinkedList<Map<String, Object>> pushMessageList = new LinkedList<>();
        LocalDate nowDate = LocalDate.now();
        // 获取每个服务商下的工单统计数据
        List<Map<String, Object>> orderNewsList = toolViewBoardMapper.getOrderNews(nowDate, null);

        // 获取每个服务商的高管和管理员id进行存储
        for (Map<String, Object> orderNews : orderNewsList) {
            String sId = orderNews.get("s_id").toString();
            // 根据服务商id获取高管和管理员账号信息
            List<User> userInfoList = userDao.getUserInfoOfServerAdminBySid(sId);
            LocalDateTime now = LocalDateTime.now();
            LocalDateTime pushTime = LocalDateTime.of(now.getYear(), now.getMonth(), now.getDayOfMonth(), 20, 16, 0);
            for (User userInfo : userInfoList) {
                // 判断账号如果是管理员，添加推送信息
                String content = String.format(contentTemplate, now.getHour(),
                        orderNews.get("waitService").toString(),
                        orderNews.get("waitMoneyBack").toString(),
                        orderNews.get("waitPayment").toString());
                if (Constants.ROLE_GLY.equals(userInfo.getR_id())) {
                    pushMessageList.add(this.pushMessageOrderNewsParams(userInfo.getId(), DateUtil.formatTime(pushTime), content, sId));
                } else if (Constants.ROLE_GG.equals(userInfo.getR_id())) {
                    if (((long) orderNews.get("waitService") != 0
                            && (long) orderNews.get("waitMoneyBack") != 0 && (long) orderNews.get("waitPayment") != 0)) {
                        // 是高管的话，查询当前管辖区域内的工单数据
                        Map<String, Object> permissionMap = new HashMap<>(10);
                        // 获取管辖区域
                        this.setPrecinctRegionsInReqMap(userInfo, permissionMap);
                        permissionMap.put("s_id", userInfo.getS_id());
                        // 获取高管管辖区域下的工单统计数据
                        List<Map<String, Object>> ggOrderNewsList = toolViewBoardMapper.getOrderNews(nowDate, permissionMap);
                        if (ggOrderNewsList.size() == 0) {
                            continue;
                        }
                        content = String.format(contentTemplate, now.getHour(),
                                ggOrderNewsList.get(0).get("waitService").toString(),
                                ggOrderNewsList.get(0).get("waitMoneyBack").toString(),
                                ggOrderNewsList.get(0).get("waitPayment").toString());
                    }
                    pushMessageList.add(this.pushMessageOrderNewsParams(userInfo.getId(), DateUtil.formatTime(pushTime), content, sId));
                }
            }
        }
        if (pushMessageList.size() == 0) {
            return;
        }

        for (Map<String, Object> message : pushMessageList) {
            // 消息中心的消息记录
            Map<String, Object> messageRecord = this.generateOrderInfoMessageRecord(message.get("s_id").toString(),
                    message.get("push_content").toString(), message.get("push_user_id").toString(),
                    this.getExtraParams(PushConstants.KEY_TODAY_ORDER, ""));
            messageRecordDao.addMessageRecord(messageRecord);
            // 批量消息推送
            jiGuangPushUtil.publishMessagePush(message, PushConstants.KEY_TODAY_ORDER, "", messageRecord.get("id").toString());
        }
    }

    /**
     * 创建app推送车辆计信息
     */
    // @Scheduled(cron = "0 0 20 * * ? ")
    public void createPushCarInfo() {
        String contentTemplate = "今日车辆速报 " +
                "截止到今日%s点，共有%s车辆在线，%s辆车故障报修，所有车辆共工作%s小时，查看详情>>>";

        LinkedList<Map<String, Object>> pushMessageList = new LinkedList<>();
        LocalDate nowDate = LocalDate.now();
        LocalDateTime nowTime = LocalDateTime.now();
        LocalDateTime pushTime = LocalDateTime.of(nowDate.getYear(), nowDate.getMonth(), nowDate.getDayOfMonth(), 20, 36, 0);

        // List<Map<String, Object>> serverList = userDao.getAllServerHasCar();

        // 车辆在线数量 车辆故障报修数量
        List<Map<String, Object>> carNewsList = toolViewBoardMapper.getCarNews(nowDate, null);
        for (Map<String, Object> carNews : carNewsList) {
            String sId = carNews.get("s_id").toString();
            String onlineNum = carNews.get("onlineNum").toString();
            String repairNum = carNews.get("repairNum").toString();
            List<String> workHoursList = toolViewBoardMapper.listWorkHoursJsonBySid(sId, nowDate);
            Double workHours = CarDataStatisticsUtil.round(workHoursList.stream().mapToDouble(workhours -> {
                Map<String, Object> hoursMap = JSON.parseObject(workhours);
                return Double.valueOf(hoursMap.get("workHours").toString());
            }).sum(), 1);

            String content = String.format(contentTemplate, nowTime.getHour(), onlineNum, repairNum, workHours);

            // 根据服务商id获取高管和管理员账号信息
            List<User> userInfoList = userDao.getUserInfoOfServerAdminBySid(sId);
            Map<String, String> precinctRegionsRepairNum = new HashMap<>(16);
            for (User userInfo : userInfoList) {
                // 如果是高管，则重新获取报修工单数量
                if (Constants.ROLE_GG.equals(userInfo.getR_id()) && Integer.valueOf(repairNum) > 0) {
                    Map<String, Object> permissionMap = new HashMap<>(10);
                    // 获取管辖区域
                    this.setPrecinctRegionsInReqMap(userInfo, permissionMap);
                    permissionMap.put("s_id", userInfo.getS_id());
                    String repairNumObj = precinctRegionsRepairNum.get(permissionMap.get("precinctRegions").toString());
                    if (repairNumObj != null) {
                        repairNum = repairNumObj;
                    } else {
                        repairNum = toolViewBoardMapper.getCarNews(nowDate, permissionMap).get(0).get("repairNum").toString();
                        precinctRegionsRepairNum.put(permissionMap.get("precinctRegions").toString(), repairNum);
                    }
                }
                pushMessageList.add(this.pushMessageCarNewsParams(userInfo.getId(), DateUtil.formatTime(pushTime), content, sId));
            }
        }
        if (pushMessageList.size() == 0) {
            return;
        }
        for (Map<String, Object> message : pushMessageList) {
            // 消息中心的消息记录
            Map<String, Object> messageRecord = this.generateCarInfoMessageRecord(message.get("s_id").toString(),
                    message.get("push_content").toString(), message.get("push_user_id").toString(),
                    this.getExtraParams(PushConstants.KEY_TODAY_CAR, ""));
            messageRecordDao.addMessageRecord(messageRecord);
            // 批量消息推送
            jiGuangPushUtil.publishMessagePush(pushMessageList, PushConstants.KEY_TODAY_CAR, "", messageRecord.get("id").toString());
        }
    }

    /**
     * app推送工单节点提示信息到高管和管理员账号上
     * 客服接单 15分钟内
     * 听诊接单 15分钟内
     * 仓管配件 15分钟内
     * 修工领取配件 10分钟内
     * 到达现场- > 修工确认配件 10分钟内
     * 自检，互检 5-30分钟
     * 2分钟执行一次
     */
    @Scheduled(cron = "0 */2 * * * ? ")
//    @Scheduled(cron = "0 */1 * * * ? ")
    public void pushOrderNodeInfoToAdminNew() {
            int KFTime = 15,
                TZTime = 30,
                CGTime = 30,
                XGTime = 20,
                XGArriveTime = 10,
                minCheckTime = 5,
                maxCheckTime = 30;

        LinkedList<Map<String, Object>> pushMessageList = new LinkedList<>();
        LocalDateTime now = LocalDateTime.now();

        // 获取有工单的所有服务商
        List<Map<String, Object>> serverList = userDao.getAllServerHasOrder();

        Iterator<Map<String,Object>> iterator = serverList.iterator();
        while (iterator.hasNext()){
            Map<String,Object> server=iterator.next();

//        for (Map<String, Object> server : serverList) {
            String sId = server.get("id").toString();
            // 根据服务商ID获取所有非车主司机用户信息
//            List<User> userList = userDao.getAllUserBySid(sId);
            List<TSSsUserVO> userList = userMapper.getAllUserBySid(sId);

            // 获取超时订单列表
            List<Map<String, Object>> orderList = orderDao.getOrderTimeOutList(KFTime, TZTime, CGTime, XGTime, XGArriveTime, maxCheckTime);
            String content, extraPushRole;
            for (Map<String, Object> orderMap : orderList) {

                if(orderMap.get("id") == null){
                    continue;
                }


                String orderId = orderMap.get("id").toString();
                String orderNo = orderMap.get("order_no").toString();
                String orderEnd = orderNo.substring(orderNo.length() - 4);
                if (orderMap.get("area") == null) {
                    continue;
                }
                String area = orderMap.get("area").toString();
                // 主修工用户id
                String mainXgUserId = "";

                int orderStatus = Integer.valueOf(orderMap.get("order_status").toString());
                if (orderStatus == Constants.ORDER_STATUS_DSL) {
                    // 超出KFTime
                    // 车主名称
                    String czUserName = orderMap.get("cz_user_name")!=null?orderMap.get("cz_user_name").toString():"";
                    content = String.format(PushConstants.TEMPLATE_ORDER_NODE_KF,czUserName, KFTime);
                    extraPushRole = Constants.ROLE_KF;
//                    extraPushRole = Constants.ROLE_GG;
                } else if (orderStatus == Constants.ORDER_STATUS_DTZ) {
                    // 超出TZTime
                    String tzUserNo = orderMap.get("tz_user_no")!=null?orderMap.get("tz_user_no").toString():"";
                    content = String.format(PushConstants.TEMPLATE_ORDER_NODE_TZ, tzUserNo, orderEnd, TZTime);
                    extraPushRole = Constants.ROLE_TZ;
//                    extraPushRole = Constants.ROLE_GG;
                } else if (orderStatus == Constants.ORDER_STATUS_PJ) {
                    // 超出CGTime
                    content = String.format(PushConstants.TEMPLATE_ORDER_NODE_CG ,orderEnd, CGTime);
                    extraPushRole = Constants.ROLE_CG;
//                    extraPushRole = Constants.ROLE_GG;
                } else if (orderStatus == Constants.ORDER_STATUS_DLL) {
//                    String mainMan = orderDao.getRepairManByOrderId(orderId, true);
                    String mainMan = orderDao.getRepairManUserNoByOrderId(orderId, true);
                    mainXgUserId = orderDao.getRepairManUserIdByOrderId(orderId, true);

                    // 超出XGTime
                    content = String.format(PushConstants.TEMPLATE_ORDER_NODE_XG_RECEIVE, mainMan, orderEnd, XGTime);
                    extraPushRole = Constants.ROLE_XG;

//                    extraPushRole = Constants.ROLE_GG;
                } else if (orderStatus == Constants.ORDER_STATUS_DDXC) {
//                    String mainMan = orderDao.getRepairManByOrderId(orderId, true);
                    String mainMan = orderDao.getRepairManUserNoByOrderId(orderId, true);
                    mainXgUserId = orderDao.getRepairManUserIdByOrderId(orderId, true);
                    // 超出XGArriveTime
                    content = String.format(PushConstants.TEMPLATE_ORDER_NODE_XG_CONFIRM, mainMan, orderEnd, XGArriveTime);
                    extraPushRole = Constants.ROLE_XG;
                } else if (orderStatus == Constants.ORDER_STATUS_HJ) {
                    // 最大互检时间XGArriveTime
//                    String mainMan = orderDao.getRepairManByOrderId(orderId, null);
                    String mainMan = orderDao.getRepairManUserNoByOrderId(orderId, null);
                    mainXgUserId = orderDao.getRepairManUserIdByOrderId(orderId, null);

                    content = String.format(PushConstants.TEMPLATE_ORDER_NODE_XG_MUTUAL_CHECK, orderEnd, mainMan, KFTime);
                    extraPushRole = Constants.ROLE_XG;
                } else {
                    continue;
                }
                this.addOrderNodeRemindMessageNew(pushMessageList, userList, content, extraPushRole, DateUtil.formatTime(now), sId, orderId, orderStatus, area,mainXgUserId);
            }
        }

        if (pushMessageList.size() == 0) {
            return;
        }

        for (Map<String, Object> message : pushMessageList) {
            try {
                // 判断是否推送过，如果没有推送过就推送，推送过就跳出
                int count = pushMessageRecordMapper.getPushMessageNotificationCount(message);
                if (count == 0) {
                    String value = message.get("order_id").toString();
                    // 消息中心的消息记录
                    Map<String, Object> messageRecord = this.generateOrderNodeInfoMessageRecord(message.get("s_id").toString(),
                            message.get("push_content").toString(), message.get("push_user_id").toString(), message.get("order_id").toString(),
                            this.getExtraParams(PushConstants.KEY_ORDER_ID, value));
                    messageRecordDao.addMessageRecord(messageRecord);
                    jiGuangPushUtil.publishMessagePush(message, PushConstants.KEY_ORDER_ID, message.get("order_id").toString(), messageRecord.get("id").toString());
                    pushMessageRecordMapper.savePushMessageNotificationCount(this.generateOrderNodeNotificationRecordParams(message.get("order_id").toString(), message.get("order_status").toString(),
                            message.get("push_user_id").toString()));
                }
            } catch (Exception e) {
                logger.error(e.getMessage());
                e.printStackTrace();
            }
        }
    }

    /**
     * app推送工单节点提示信息到高管和管理员账号上
     * 客服接单 15分钟内 2
     * 听诊接单 15分钟内 3
     * 仓管配件 15分钟内 5
     * 修工领取配件 10分钟内 6
     * 到达现场- > 修工确认配件 10分钟内 9
     * 自检，互检 5-30分钟 11 12
     */
    // @Scheduled(cron = "0 */2 * * * ? ")
//    @Deprecated
//    public void pushOrderNodeInfoToAdmin() {
//        int KFTime = 15,
//                TZTime = 15,
//                CGTime = 15,
//                XGTime = 10,
//                XGArriveTime = 10,
//                minCheckTime = 5,
//                maxCheckTime = 30;
//
//        LinkedList<Map<String, Object>> pushMessageList = new LinkedList<>();
//
//        LocalDateTime now = LocalDateTime.now();
//
//        List<Map<String, Object>> serverList = userDao.getAllServerHasOrder();
//        for (Map<String, Object> server : serverList) {
//            String sId = server.get("id").toString();
//            // 根据服务商ID获取所有非车主司机用户信息
//            List<User> userList = userDao.getAllUserBySid(sId);
//
//            // 获取在某个节点下的工单
//            List<Map<String, Object>> orderList = orderDao.getAllOrderBySId(KFTime, TZTime, CGTime, XGTime, XGArriveTime, sId);
//            String content, extraPushRole;
//            for (Map<String, Object> order : orderList) {
//                String orderId = order.get("id").toString();
//                String orderNo = order.get("order_no").toString();
//                String orderEnd = orderNo.substring(orderNo.length() - 4);
//                if (order.get("area") == null) {
//                    continue;
//                }
//                String area = order.get("area").toString();
//                int orderStatus = Integer.valueOf(order.get("order_status").toString());
//                if (orderStatus == Constants.ORDER_STATUS_DSL) {
//                    // 超出KFTime
//                    content = String.format(PushConstants.TEMPLATE_ORDER_NODE_KF, order.get("cz_user_name").toString(), KFTime);
//                    extraPushRole = Constants.ROLE_KF;
//                } else if (orderStatus == Constants.ORDER_STATUS_DTZ) {
//                    // 超出TZTime
//                    content = String.format(PushConstants.TEMPLATE_ORDER_NODE_TZ, order.get("tz_user_name").toString(), orderEnd, TZTime);
//                    extraPushRole = Constants.ROLE_TZ;
//                } else if (orderStatus == Constants.ORDER_STATUS_PJ) {
//                    // 超出CGTime
//                    content = String.format(PushConstants.TEMPLATE_ORDER_NODE_CG, orderEnd, CGTime);
//                    extraPushRole = Constants.ROLE_CG;
//                } else if (orderStatus == Constants.ORDER_STATUS_DLL) {
//                    String mainMan = orderDao.getRepairManByOrderId(orderId, true);
//                    // 超出XGTime
//                    content = String.format(PushConstants.TEMPLATE_ORDER_NODE_XG_RECEIVE, mainMan, orderEnd, XGTime);
//                    extraPushRole = Constants.ROLE_XG;
//                } else if (orderStatus == Constants.ORDER_STATUS_DDXC) {
//                    String mainMan = orderDao.getRepairManByOrderId(orderId, true);
//                    // 超出XGArriveTime
//                    content = String.format(PushConstants.TEMPLATE_ORDER_NODE_XG_CONFIRM, mainMan, orderEnd, XGArriveTime);
//                    extraPushRole = Constants.ROLE_XG;
//                } else if (orderStatus == Constants.ORDER_STATUS_ZJ) {
//                    int XGNumber = Integer.valueOf(order.get("XGNumber").toString());
//                    if (XGNumber == 1) {
//                        continue;
//                    }
//                    // minCheckTime 到 maxCheckTime时间范围
//                    String selfCheckTime = order.get("selfCheckTime").toString();
//                    // 互检结束时间为null判断自检时间距离现在是否已经超过maxCheckTime时间范围
//                    if (order.get("mutualCheckTime") != null || Duration.between(DateUtil.parseTime(selfCheckTime), now).toMinutes() < maxCheckTime) {
//                        continue;
//                    }
//                    String mainMan = orderDao.getRepairManByOrderId(orderId, null);
//                    content = String.format(PushConstants.TEMPLATE_ORDER_NODE_XG_MUTUAL_CHECK, orderEnd, mainMan, KFTime);
//                    extraPushRole = Constants.ROLE_XG;
//                    /*else {
//                        // 如果互检结束时间不为null，判断互检时间是否小于minCheckTime时间范围
//                        String mutualCheckTime = order.get("mutualCheckTime").toString();
//                        if (Duration.between(DateUtil.parseTime(selfCheckTime), DateUtil.parseTime(mutualCheckTime)).toMinutes() < minCheckTime){
//                            content = String.format("工单%s修工自检互检完成时间间隔低于%d分钟", order.get("order_no").toString(), KFTime);
//                        }
//                    }*/
//                } else {
//                    continue;
//                }
//                this.addOrderNodeRemindMessage(pushMessageList, userList, content, extraPushRole, DateUtil.formatTime(now), sId, orderId, orderStatus, area);
//            }
//        }
//        if (pushMessageList.size() == 0) {
//            return;
//        }
//
//        for (Map<String, Object> message : pushMessageList) {
//            try {
//                int count = pushMessageRecordMapper.getPushMessageNotificationCount(message);
//                if (count == 0) {
//                    String value = message.get("order_id").toString();
//                    // 消息中心的消息记录
//                    Map<String, Object> messageRecord = this.generateOrderNodeInfoMessageRecord(message.get("s_id").toString(),
//                            message.get("push_content").toString(), message.get("push_user_id").toString(), message.get("order_id").toString(),
//                            this.getExtraParams(PushConstants.KEY_ORDER_ID, value));
//                    messageRecordDao.addMessageRecord(messageRecord);
//                    jiGuangPushUtil.publishMessagePush(message, PushConstants.KEY_ORDER_ID, message.get("order_id").toString(), messageRecord.get("id").toString());
//                    pushMessageRecordMapper.savePushMessageNotificationCount(this.generateOrderNodeNotificationRecordParams(message.get("order_id").toString(), message.get("order_status").toString(),
//                            message.get("push_user_id").toString()));
//                }
//            } catch (Exception e) {
//                logger.error(e.getMessage());
//                e.printStackTrace();
//            }
//        }
//    }

    public void addOrderNodeRemindMessageNew(LinkedList<Map<String, Object>> pushMessageList,
                                          List<TSSsUserVO> userList, String content, String extraPushRole, String time,
                                          String sId, String orderId, Integer orderStatus, String area,String mainXgUserId) {
        for (TSSsUserVO user : userList) {
            if (Constants.ROLE_GLY.equals(user.getRId()) ) {
                pushMessageList.add(this.pushMessageOrderNodeRemindParams(user.getId(), time, content, sId, orderId, orderStatus));

            } else if (extraPushRole.equals(user.getRId())) {
                // 除了推送给高管和管理员外，还得给对应的负责人一个超时推送提醒
                // 推送给订单对应的仓管和修工，听诊，而不是所有的
                if(extraPushRole.equals(Constants.ROLE_CG)){
                    List<TSSsUserVO> cgList = tsSsUserService.listCgByOrderId(orderId);
                    if(cgList!=null){
                        cgList.forEach(item->{
                            pushMessageList.add(this.pushMessageOrderNodeRemindParams(item.getId(), time, content, sId, orderId, orderStatus));
                        });
                    }

                }else if(extraPushRole.equals(Constants.ROLE_XG)){
                    // 推送给订单对应的主修工
                    if(user.getId().equals(mainXgUserId)){
                        pushMessageList.add(this.pushMessageOrderNodeRemindParams(user.getId(), time, content, sId, orderId, orderStatus));
                    }

                }else{
                    pushMessageList.add(this.pushMessageOrderNodeRemindParams(user.getId(), time, content, sId, orderId, orderStatus));
                }
            } else if (Constants.ROLE_GG.equals(user.getRId())) {
                Map<String, Object> permissionMap = new HashMap<>(10);
                // 获取管辖区域
                // 兼容之前的方法
                User userOld = new User();
//                BeanUtils.copyProperties(user,userOld);
                userOld.setId(user.getId());
                userOld.setArea(user.getArea());
                userOld.setR_id(user.getRId());
                userOld.setS_id(user.getSId());
                this.setPrecinctRegionsInReqMap(userOld, permissionMap);
                String precinctRegions = permissionMap.get("precinctRegions").toString();
                if (precinctRegions.contains(area)) {
                    pushMessageList.add(this.pushMessageOrderNodeRemindParams(user.getId(), time, content, sId, orderId, orderStatus));
                }
            }
        }
    }

//    public void addOrderNodeRemindMessage(LinkedList<Map<String, Object>> pushMessageList,
//                                          List<User> userList, String content, String extraPushRole, String time,
//                                          String sId, String orderId, Integer orderStatus, String area) {
//        for (User user : userList) {
//            if (Constants.ROLE_GLY.equals(user.getR_id()) || extraPushRole.equals(user.getR_id())) {
//                pushMessageList.add(this.pushMessageOrderNodeRemindParams(user.getId(), time, content, sId, orderId, orderStatus));
//            } else if (Constants.ROLE_GG.equals(user.getR_id())) {
//                Map<String, Object> permissionMap = new HashMap<>(10);
//                // 获取管辖区域
//                this.setPrecinctRegionsInReqMap(user, permissionMap);
//                String precinctRegions = permissionMap.get("precinctRegions").toString();
//                if (precinctRegions.contains(area)) {
//                    pushMessageList.add(this.pushMessageOrderNodeRemindParams(user.getId(), time, content, sId, orderId, orderStatus));
//                }
//            }
//        }
//    }

    /**
     * 通知栏/消息栏
     * 车辆工作小时达到保养的工时（车主/司机、客服）
     */
    // @Scheduled(cron = "0 */5 * * * ?")
    public void carWorkHoursReachMaintenance() {
        LocalDateTime nowTime = LocalDateTime.now();
        String nowTimeStr = DateUtil.formatTime(nowTime);
        LinkedList<Map<String, Object>> messageList = new LinkedList<>();
        // 获取车辆到达该保养时间却没保养的所有车辆
        List<Map<String, Object>> workHoursReachMaintenance = toolCarDataMapper.getWorkHoursReachMaintenance();
        if (workHoursReachMaintenance.size() > 0) {
            messageList = this.wrapDataHandle(workHoursReachMaintenance, 3, nowTimeStr);
        }

        if (messageList.size() != 0) {
            for (Map<String, Object> message : messageList) {
                try {
                    Map<String, Object> params = new HashMap<>();
                    params.put("maintain", message.get("maintain"));
                    params.put("m_id", message.get("m_id"));
                    params.put("c_id", message.get("car_id"));
                    params.put("brand", message.get("brand"));
                    params.put("car_type", message.get("car_type"));
                    params.put("model", message.get("model"));
                    params.put("things_id", message.get("things_id"));
                    params.put("contacts", message.get("contacts"));
                    params.put("phone", message.get("phone"));
                    params.put("car_no", message.get("car_no"));
                    params.put("longitude", message.get("GPSlongitude"));
                    params.put("latitude", message.get("GPSlatitude"));
                    params.put("user_id", message.get("o_id"));
                    params.put("fault_desc", "");
                    int count = pushMessageRecordMapper.getPushMessageNotificationCount(message);
                    if (count == 0) {
                        String value = JSON.toJSONString(params);
                        Map<String, Object> messageRecord = this.generateCarMaintenanceMessageRecord(message.get("s_id").toString(),
                                message.get("push_content").toString(), message.get("push_user_id").toString(),
                                message.get("car_id").toString(), this.getExtraParams(PushConstants.KEY_PUSH_CAR_MAINTENANCE, value));
                        messageRecordDao.addMessageRecord(messageRecord);

                        // 推送消息并且保存推送信息
                        jiGuangPushUtil.publishMessagePush(message, PushConstants.KEY_PUSH_CAR_MAINTENANCE, value, messageRecord.get("id").toString());
                        // 保存推送次数
                        pushMessageRecordMapper.savePushMessageNotificationCount(this.generateCarMaintenanceNotificationRecordParams(message.get("things_id").toString(), message.get("car_id").toString(), message.get("push_user_id").toString()));
                    }
                } catch (Exception e) {
                    logger.error(e.getMessage());
                }
            }
        }
    }

    private String getExtraParams(String key, String value) {
        Map<String, Object> extraParamsMap = new HashMap<>();
        extraParamsMap.put(key, value);
        return JSON.toJSONString(extraParamsMap);
    }

    /**
     * 通知栏/消息栏
     * 车辆油位低于20%的时候（车主/司机、客服）
     */
    // @Scheduled(cron = "0 */5 * * * ? ")
    public void carFuelGaugeLowPushTask() {
        LocalDateTime nowTime = LocalDateTime.now();
        String nowTimeStr = DateUtil.formatTime(nowTime);
        LocalDate nowDate = LocalDate.now();
        LinkedList<Map<String, Object>> messageList = new LinkedList<>();
        // 油量低于20%的所有设备
        List<Map<String, Object>> fuelGaugeLowDevices = toolCarDataMapper.getFuelGaugeDataStatics(nowDate, 20);
        if (fuelGaugeLowDevices.size() > 0) {
            messageList = this.wrapDataHandle(fuelGaugeLowDevices, 1, nowTimeStr);
        }

        if (messageList.size() != 0) {
            for (Map<String, Object> message : messageList) {
                try {
                    int count = pushMessageRecordMapper.getPushMessageNotificationCount(message);
                    if (count == 0) {
                        Map<String, Object> messageRecord = this.generateCarFuelGuageLowMessageRecord(message.get("s_id").toString(),
                                message.get("push_content").toString(), message.get("push_user_id").toString(), message.get("car_id").toString(),
                                this.getExtraParams(PushConstants.KEY_PUSH_CAR_FUEL_GUAGE_LOW, ""));
                        messageRecordDao.addMessageRecord(messageRecord);

                        // 推送消息并且保存推送信息
                        jiGuangPushUtil.publishMessagePush(message, PushConstants.KEY_PUSH_CAR_FUEL_GUAGE_LOW, "", messageRecord.get("id").toString());
                        // 保存推送次数
                        pushMessageRecordMapper.savePushMessageNotificationCount(this.generateCarFuelGaugeLowNotificationRecordParams(message.get("things_id").toString(), message.get("push_user_id").toString()));
                    }
                } catch (Exception e) {
                    logger.error(e.getMessage());
                }
            }
        }
    }

    /**
     * 通知栏/消息栏
     * 车辆报出故障代码的时候（车主/司机、客服）
     */
    // @Scheduled(cron = "0 */5 * * * ? ")
    public void carFaultPushTask() {
        LocalDateTime nowTime = LocalDateTime.now();
        String nowTimeStr = DateUtil.formatTime(nowTime);
        LocalDate nowDate = LocalDate.now();
        LinkedList<Map<String, Object>> messageList = new LinkedList<>();
        // 故障设备
        List<Map<String, Object>> faultDevices = toolCarDataMapper.getFaultDataStatics(nowDate);
        if (faultDevices.size() > 0) {
            messageList = this.wrapDataHandle(faultDevices, 2, nowTimeStr);
        }

        if (messageList.size() != 0) {
            for (Map<String, Object> message : messageList) {
                try {
                    Map<String, Object> params = new HashMap<>();
                    params.put("c_id", message.get("car_id"));
                    params.put("brand", message.get("brand"));
                    params.put("car_type", message.get("car_type"));
                    params.put("model", message.get("model"));
                    params.put("things_id", message.get("things_id"));
                    params.put("contacts", message.get("contacts"));
                    params.put("phone", message.get("phone"));
                    params.put("car_no", message.get("car_no"));
                    params.put("longitude", message.get("GPSlongitude"));
                    params.put("latitude", message.get("GPSlatitude"));
                    params.put("user_id", message.get("o_id"));
                    params.put("fault_desc", message.get("fault_desc"));
                    // 推送消息并且保存推送信息
                    String value = JSON.toJSONString(params);
                    Map<String, Object> messageRecord = this.generateCarFaultMessageRecord(message.get("s_id").toString(),
                            message.get("push_content").toString(), message.get("push_user_id").toString(), message.get("car_id").toString(),
                            this.getExtraParams(PushConstants.KEY_PUSH_CAR_FAULT, value));
                    messageRecordDao.addMessageRecord(messageRecord);
                    jiGuangPushUtil.publishMessagePush(message, PushConstants.KEY_PUSH_CAR_FAULT, value, messageRecord.get("id").toString());
                    String[] spnFmis = message.get("spn_fmi").toString().split(",");
                    if (spnFmis.length > 0) {
                        for (String spnFmi : spnFmis) {
                            String[] spn_fmi = spnFmi.split("-");
                            String spn = spn_fmi[0];
                            String fmi = spn_fmi[1];
                            message.put("fault_spn", spn);
                            message.put("fault_fmi", fmi);
                            int count = pushMessageRecordMapper.getPushMessageNotificationCount(message);
                            if (count == 0) {
                                // 保存推送次数
                                pushMessageRecordMapper.savePushMessageNotificationCount(
                                        this.generateCarFaultNotificationRecordParams(message.get("things_id").toString(),
                                                message.get("car_id").toString(), spn, fmi, message.get("push_user_id").toString()));
                            }
                        }
                    }
                } catch (Exception e) {
                    logger.error(e.getMessage());
                    e.printStackTrace();
                }
            }
        }
    }

    /**
     * 通知栏
     * 每天推送一条实时新闻 (所有用户)
     */
    @Scheduled(cron = "0 30 10 * * ? ")
    public void everyDayPushNews() {
        Map<String, Object> news = shangJiMapper.lastNewsToday();
        if (news != null) {
            String pushTime = DateUtil.formatTime(LocalDateTime.now());
            Map<String, Object> message = this.pushMessageEveryNewsParams(pushTime, news.get("title").toString());

            jiGuangPushUtil.publishMessagePushAll(message, PushConstants.KEY_NEW_ID, news.get("uuid").toString());

//            message.put("push_user_id", "u53859793");
//            jiGuangPushUtil.publishMessagePush(message, PushConstants.KEY_NEW_ID, news.get("uuid").toString());
        }
    }

    /**
     * 通知栏
     * 用户行为得分高的数据类型推送
     */
    //@Scheduled(cron = "0 30 15 * * ? ")
    public void userBehaviorAnalysis() {
        // 用户行为数据
        List<Map<String, Object>> userBehaviors = shangJiMapper.userBehaviorCoreHigh();

        //device, user_id, behavior_type 复合主键
        LinkedList<Map<String, Object>> messageList = new LinkedList<>();
        String pushTime = DateUtil.formatTime(LocalDateTime.now());

        for (Map<String, Object> userBehavior : userBehaviors) {
            int behaviorType = Integer.valueOf(userBehavior.get("behavior_type").toString());
            String pushContent = String.format(PushConstants.TEMPLATE_USER_REGARD_INFO, this.getBehaviorModuleName(behaviorType));
            if (userBehavior.get("user_id") != null && StringUtils.isNotBlank(userBehavior.get("user_id").toString())) {
                String userId = userBehavior.get("user_id").toString();
                messageList.addLast(this.pushMessageBehaviorParams(userId, pushTime, pushContent, behaviorType));
            }
            if (userBehavior.get("device") != null && StringUtils.isNotBlank(userBehavior.get("device").toString())) {
                String device = userBehavior.get("device").toString();
                messageList.addLast(this.pushMessageBehaviorParams(device, pushTime, pushContent, behaviorType));
            }
        }

        for (Map<String, Object> message : messageList) {
            int behavior = Integer.valueOf(message.get("behavior_type").toString());
            String key = null;
            if (behavior == Constants.BEHAVIOR_BID_TYPE) {
                key = PushConstants.KEY_ZHAOBIAO_LIST;
            } else if (behavior == Constants.BEHAVIOR_RECRUIT_TYPE) {
                key = PushConstants.KEY_JOBER_RECRUIT_LIST;
            } else if (behavior == Constants.BEHAVIOR_SALEANDRENT_TYPE) {
                key = PushConstants.KEY_ZUSHOU_LIST;
            } else if (behavior == Constants.BEHAVIOR_SHOP_TYPE) {
                key = PushConstants.KEY_SHOP_LIST;
            }

            jiGuangPushUtil.publishMessagePush(message, key, "");
        }
    }

    private String getBehaviorModuleName(int behavior) {
        if (behavior == Constants.BEHAVIOR_BID_TYPE) {
            return "招中标";
        } else if (behavior == Constants.BEHAVIOR_RECRUIT_TYPE) {
            return "求职招聘";
        } else if (behavior == Constants.BEHAVIOR_SALEANDRENT_TYPE) {
            return "租售";
        } else if (behavior == Constants.BEHAVIOR_SHOP_TYPE) {
            return "维修服务";
        }
        return "";
    }

    private LinkedList<Map<String, Object>> wrapDataHandle(List<Map<String, Object>> datas, int type, String nowTimeStr) {
        LinkedList<Map<String, Object>> messageList = new LinkedList<>();
        String[] thingss = datas.stream().map(map -> map.get("things_id").toString()).distinct().toArray(String[]::new);
        List<Map<String, Object>> ownerCars = toolCarDataMapper.getOwnerCarByThingss(String.join(",", thingss));
        List<String> carMasters = new LinkedList<>();
        if (ownerCars.size() > 0) {
            // 服务商id
            String sId = ownerCars.get(0).get("s_id").toString();
            // 车主id
            String oId = ownerCars.get(0).get("o_id").toString();
            // 获取客服id
            List<Map<String, Object>> users = toolCarDataMapper.getUserBySIdAndRId(sId, Constants.ROLE_KF);
            // 获取司机id
            for (Map<String, Object> ownerCar : ownerCars) {

                String carType = ownerCar.get("car_type").toString();
                String model = ownerCar.get("model").toString();
                String brand = ownerCar.get("brand").toString();
                String carId = ownerCar.get("c_id").toString();
                Map<String, Object> params = new HashMap<>();

                String thingsId = ownerCar.get("things_id").toString();
                Map<String, Object> map = this.getItemByKey(datas, thingsId);
                String pushContent = null,
                        faultSpn = null,
                        faultFmi = null;

                // 根据type判断是油量低
                if (type == 1) {
                    double fuelGauge = Double.valueOf(map.get("fuel_gauge").toString());
                    String param = String.valueOf((int) fuelGauge);
                    pushContent = String.format(PushConstants.TEMPLATE_CAR_FUEL_GUAGE_LOW, carType, model, brand, param);
                } else if (type == 2) {
                    // 有故障
                    params.put("brand", brand);
                    params.put("car_type", carType);
                    params.put("model", model);
                    params.put("contacts", ownerCar.get("user_name").toString());
                    params.put("phone", ownerCar.get("mobile_phone").toString());
                    params.put("car_no", ownerCar.get("car_no") == null ? "" : ownerCar.get("car_no").toString());
                    params.put("GPSlongitude", map.get("GPSlongitude").toString());
                    params.put("GPSlatitude", map.get("GPSlatitude").toString());
                    params.put("spn_fmi", getSpnFmi(datas, "spn_fmi"));
                    params.put("o_id", oId);
                    String param = getFaultDesc(datas, thingsId);
                    params.put("fault_desc", param);
                    pushContent = String.format(PushConstants.TEMPLATE_CAR_FAULT, carType, model, brand, param);
                } else if (type == 3) {
                    // 保养
                    String param = map.get("running").toString();
                    String param1 = map.get("upkeep_time").toString();
                    params.put("maintain", param1);
                    params.put("m_id", map.get("upkeep_id").toString());
                    params.put("brand", brand);
                    params.put("car_type", carType);
                    params.put("model", model);
                    params.put("contacts", ownerCar.get("user_name").toString());
                    params.put("phone", ownerCar.get("mobile_phone").toString());
                    params.put("car_no", ownerCar.get("car_no") == null ? "" : ownerCar.get("car_no").toString());
                    params.put("GPSlongitude", map.get("GPSlongitude") == null ? "" : map.get("GPSlongitude").toString());
                    params.put("GPSlatitude", map.get("GPSlatitude") == null ? "" : map.get("GPSlatitude").toString());
                    params.put("fault_desc", "");
                    params.put("o_id", oId);
                    pushContent = String.format(PushConstants.TEMPLATE_CAR_WORK_REMIND, carType, model, brand, param, param1);
                }
                if (pushContent == null) {
                    continue;
                }
                // 车主相同车辆 只推送一次
                if (!carMasters.contains(oId + thingsId)) {
                    carMasters.add(oId + thingsId);
                    // 添加车主推送信息
                    messageList.addLast(this.getParamsByType(type, oId, nowTimeStr, pushContent, thingsId, carId, sId, params));
                }
                // 添加司机推送信息
                if (ownerCar.get("d_id") != null) {
                    String dId = ownerCar.get("d_id").toString();
                    messageList.addLast(this.getParamsByType(type, dId, nowTimeStr, pushContent, thingsId, carId, sId, params));
                }

                // 客服推送信息
                for (Map<String, Object> kfUser : users) {
                    String userId = kfUser.get("id").toString();
                    if (type == 3) {
                        String param = ownerCar.get("user_name").toString();
                        String param1 = String.valueOf(map.get("running"));
                        Integer param2 = (Integer) map.get("upkeep_time");
                        pushContent = String.format(PushConstants.TEMPLATE_CAR_WORK_REMIND_KF, param, carType, model, brand, param1, param2);
                    }
                    messageList.addLast(this.getParamsByType(type, userId, nowTimeStr, pushContent, thingsId, carId, sId, params));
                }
            }
        }
        return messageList;
    }

    private String getFaultDesc(Map<String, Object> map) {
        String[] spnFmis = map.get("spn_fmi").toString().split(",");
        String[] spnDescriptionFmiDescription = map.get("spnDescription_fmiDescription").toString().split(",");

        StringBuilder faultDesc = new StringBuilder();
        for (int i = 0; i < spnFmis.length; i++) {
            faultDesc.append(spnFmis[i])
                    .append("_")
                    .append(spnDescriptionFmiDescription[i])
                    .append(" ");
        }
        return faultDesc.toString();
    }

    private String getFaultDesc(List<Map<String, Object>> maps, String thingsId) {
        StringBuilder faultDesc = new StringBuilder();
        for (Map<String, Object> map : maps) {

            if (thingsId.equals(map.get("things_id").toString())) {
                String[] spnFmis = map.get("spn_fmi").toString().split(",");
                String[] spnDescriptionFmiDescription = map.get("spnDescription_fmiDescription").toString().split(",");

                for (int i = 0; i < spnFmis.length; i++) {
                    faultDesc.append(spnFmis[i])
                            .append("_")
                            .append(spnDescriptionFmiDescription[i])
                            .append(" ");
                }
            }
        }
        return faultDesc.toString();
    }

    private String getSpnFmi(List<Map<String, Object>> maps, String keySpnFmi) {
        LinkedList<String> spnFmis = new LinkedList<>();
        for (Map<String, Object> map : maps) {
            spnFmis.addLast(map.get(keySpnFmi).toString());
        }
        return String.join(",", spnFmis);
    }

    private String getFaultDesc(String thingsId) {
        List<Map<String, Object>> faultDetails = toolCarDataMapper.getFaultDetails(thingsId);

        if (faultDetails.size() > 0) {
            String faultTemplateType = faultDetails.get(0).get("fault_template_type").toString();
            // 卡特故障类型
            if (Constants.CAR_FALUT_TYPE_KT.equals(faultTemplateType)) {
                // spn-fmi spn_desc-fmi_desc
                String template = "%s-%s %s-%s\n";
                StrBuilder faultDesc = new StrBuilder();
                for (Map<String, Object> faultDetail : faultDetails) {
                    String spn = faultDetail.get("spn") != null ? faultDetail.get("spn").toString() : "";
                    String fmi = faultDetail.get("fmi") != null ? faultDetail.get("fmi").toString() : "";
                    String spnDescription = faultDetail.get("spn_description") != null ? faultDetail.get("spn_description").toString() : "";
                    String fmiDescription = faultDetail.get("fmi_description") != null ? faultDetail.get("fmi_description").toString() : "";
                    faultDesc.append(String.format(template, spn, fmi, spnDescription, fmiDescription));
                }
                return faultDesc.toString();

            } else if (Constants.CAR_FALUT_TYPE_ZT.equals(faultTemplateType)) {
                // todo 保留钻通处理
            } else {
                return "";
            }
        }
        return "";
    }

    private Map<String, Object> getParamsByType(Integer type, String pushId, String nowTimeStr, String pushContent,
                                                String thingsId, String carId, String sId, Map<String, Object> params) {
        params.put("things_id", thingsId);
        params.put("car_id", carId);
        params.put("s_id", sId);
        return getParamsByType(type, pushId, nowTimeStr, pushContent, params);
    }

    private Map<String, Object> getParamsByType(Integer type, String pushId, String nowTimeStr, String pushContent, Map<String, Object> params) {
        if (type == 1) {
            return this.pushMessageCarFuelGaugeParams(pushId, nowTimeStr, pushContent, params);
        } else if (type == 2) {
            return this.pushMessageCarFaultParams(pushId, nowTimeStr, pushContent, params);
        } else if (type == 3) {
            return this.pushMessageCarMaintenanceParams(pushId, nowTimeStr, pushContent, params);
        }
        return null;
    }

    private Object getValueByKey(List<Map<String, Object>> datas, String thingsId, String key) {
        return this.getValueByKey(datas, thingsId, key, null);
    }

    private Map<String, Object> getItemByKey(List<Map<String, Object>> datas, String thingsId) {
        for (Map<String, Object> data : datas) {
            if (thingsId.equals(data.get("things_id").toString())) {
                return data;
            }
        }
        return null;
    }

    private Object getValueByKey(List<Map<String, Object>> datas, String thingsId, String key, String key2) {
        for (Map<String, Object> data : datas) {
            if (thingsId.equals(data.get("things_id").toString())) {
                if (key2 == null) {
                    return data.get(key);
                } else {
                    return data.get(key) + "-" + data.get(key2);
                }
            }
        }
        return null;
    }

    /**
     * 生成车辆保养推送次数记录 参数
     *
     * @param thingsId
     * @param carId
     * @param pushUserId
     * @return
     */
    private Map<String, Object> generateCarMaintenanceNotificationRecordParams(String thingsId, String carId, String pushUserId) {
        return this.generateNotificationRecordParams(null, null, pushUserId, 5, thingsId, carId);
    }

    /**
     * 生成车辆油位低推送次数记录 参数
     *
     * @param thingsId
     * @param pushUserId
     * @return
     */
    private Map<String, Object> generateCarFuelGaugeLowNotificationRecordParams(String thingsId, String pushUserId) {
        return this.generateNotificationRecordParams(null, null, pushUserId, 6, thingsId);
    }

    /**
     * 生成车辆故障推送次数记录 参数
     *
     * @param thingsId
     * @param pushUserId
     * @return
     */
    private Map<String, Object> generateCarFaultNotificationRecordParams(String thingsId, String carId, String faultSpn, String faultFmi, String pushUserId) {
        return this.generateNotificationRecordParams(null, null, pushUserId, 7, thingsId, carId, faultFmi, faultSpn);
    }


    /**
     * 生成工单节点推送次数记录 参数
     *
     * @param orderId
     * @param orderStatus
     * @param pushUserId
     * @return
     */
    private Map<String, Object> generateOrderNodeNotificationRecordParams(String orderId, String orderStatus, String pushUserId) {
        return this.generateNotificationRecordParams(orderId, orderStatus, pushUserId, 3, null);
    }

    /**
     * 生成推送通知次数记录 参数
     *
     * @param orderId
     * @param orderStatus
     * @param pushUserId
     * @param notificationType
     * @param thingsId
     * @return
     */
    private Map<String, Object> generateNotificationRecordParams(String orderId, String orderStatus, String pushUserId, int notificationType, String thingsId) {
        return this.generateNotificationRecordParams(orderId, orderStatus, pushUserId, notificationType, thingsId, null, 1, "system", null, null);
    }

    private Map<String, Object> generateNotificationRecordParams(String orderId, String orderStatus, String pushUserId, int notificationType, String thingsId, String carId) {
        return this.generateNotificationRecordParams(orderId, orderStatus, pushUserId, notificationType, thingsId, carId, 1, "system", null, null);
    }

    private Map<String, Object> generateNotificationRecordParams(String orderId, String orderStatus, String pushUserId, int notificationType, String thingsId, String carId, String faultFmi, String faultSpn) {
        return this.generateNotificationRecordParams(orderId, orderStatus, pushUserId, notificationType, thingsId, carId, 1, "system", faultFmi, faultSpn);
    }

    /**
     * 生成推送通知次数记录 参数
     *
     * @param orderId
     * @param orderStatus
     * @param pushUserId
     * @param notificationType 0-无 3-工单节点 5-车辆保养 6-车辆油位低 7-车辆故障
     * @param thingsId
     * @param pushNumber
     * @param createUser
     * @return
     */
    private Map<String, Object> generateNotificationRecordParams(String orderId, String orderStatus, String pushUserId, int notificationType, String thingsId,
                                                                 String carId, int pushNumber, String createUser, String faultFmi,
                                                                 String faultSpn) {
        Map<String, Object> params = new HashMap<>();
        params.put("order_id", orderId);
        params.put("order_status", orderStatus);
        params.put("push_user_id", pushUserId);
        params.put("push_number", pushNumber);
        params.put("notification_type", notificationType);
        params.put("things_id", thingsId);
        params.put("car_id", carId);
        params.put("create_user", createUser);
        params.put("fault_fmi", faultFmi);
        params.put("fault_spn", faultSpn);
        return params;
    }


    // 14-车辆工作小时达到保养的工时 15-车辆油位低于x%的时候 16-车辆报出故障代码的时候
    private Map<String, Object> generateCarMaintenanceMessageRecord(String sId, String context, String receiveUser, String carId, String extraParams) {
        return this.generateMessageRecordParamsHasId(sId, 14, context, "system", receiveUser, carId, null, "YD", extraParams);
    }

    private Map<String, Object> generateCarFuelGuageLowMessageRecord(String sId, String context, String receiveUser, String carId, String extraParams) {
        return this.generateMessageRecordParamsHasId(sId, 15, context, "system", receiveUser, carId, null, "YD", extraParams);
    }

    private Map<String, Object> generateCarFaultMessageRecord(String sId, String context, String receiveUser, String carId, String extraParams) {
        return this.generateMessageRecordParamsHasId(sId, 16, context, "system", receiveUser, carId, null, "YD", extraParams);
    }

    private Map<String, Object> generateOrderInfoMessageRecord(String sId, String context, String receiveUser, String extraParams) {
        return this.generateMessageRecordParamsHasId(sId, 17, context, "system", receiveUser, null, null, "YD", extraParams);
    }

    private Map<String, Object> generateCarInfoMessageRecord(String sId, String context, String receiveUser, String extraParams) {
        return this.generateMessageRecordParamsHasId(sId, 18, context, "system", receiveUser, null, null, "YD", extraParams);
    }

    private Map<String, Object> generateOrderNodeInfoMessageRecord(String sId, String context, String receiveUser, String orderId, String extraParams) {
        return this.generateMessageRecordParamsHasId(sId, 0, context, "system", receiveUser, null, orderId, "YD", extraParams);
    }

    private Map<String, Object> generateCarMaintenanceForZTMessageRecord(String sId, String title, String context, String receiveUser, String carId, String extraParams) {
        return this.generateMessageRecordParamsHasId(sId, 19, title, context, "system", receiveUser, carId, null, "YD", extraParams);
    }

    private Map<String, Object> generateCarFreeWarningMessageRecord(String sId,String title, String context, String receiveUser, String carId, String extraParams) {
        return this.generateMessageRecordParamsHasId(sId, 101, title, context, "system", receiveUser, carId, null, "YD", extraParams);
    }

    private Map<String, Object> generateZhaoBiaoMessageRecord(String sId, String title, String context, String receiveUser, String carId, String extraParams) {
        return this.generateMessageRecordParamsHasId(sId, 20, title, context, "system", receiveUser, carId, null, "YD", extraParams);
    }

    private Map<String, Object> generateMessageRecordParamsHasId(String sId, Integer sendType, String context, String pushUser,
                                                                 String receiveUser, String carId, String orderId, String client, String extraParams) {
        Map<String, Object> params = this.generateMessageRecordParams(sId, sendType, context, pushUser, receiveUser, carId, orderId, client, extraParams);
        params.put("id", UuidUtil.get32UUID());
        return params;
    }

    private Map<String, Object> generateMessageRecordParamsHasId(String sId, Integer sendType, String title, String context, String pushUser,
                                                                 String receiveUser, String carId, String orderId, String client, String extraParams) {
        Map<String, Object> params = this.generateMessageRecordParams(sId, sendType, title, context, pushUser, receiveUser, carId, orderId, client, extraParams);
        params.put("id", UuidUtil.get32UUID());
        return params;
    }

    /**
     * @param sId
     * @param sendType    发送类型 0-工单提示信息 7：电子围栏报警 8：实数数据超限报警 9：故障码报警 10：访问
     *                    11：收藏 12：转发 13：申请解锁
     *                    14-车辆工作小时达到保养的工时 15-车辆油位低于x%的时候 16-车辆报出故障代码的时候',
     *                    17-今日工单速报 18-今日车辆速报 19-车辆工作小时达到保养的工时(钻通)
     * @param context
     * @param pushUser
     * @param receiveUser
     * @param carId
     * @param orderId
     * @param client
     * @return
     */
    private Map<String, Object> generateMessageRecordParams(String sId, Integer sendType, String context, String pushUser,
                                                            String receiveUser, String carId, String orderId, String client,
                                                            String extraParams) {
        Map<String, Object> params = new HashMap<>();
        params.put("s_id", sId);
        params.put("send_type", sendType);
        params.put("context", context);
        params.put("push_user", pushUser);
        params.put("receive_user", receiveUser);
        params.put("c_id", carId);
        params.put("order_id", orderId);
        params.put("client", client);
        params.put("is_flag", 1);
        params.put("status", 0);
        params.put("send_grade", null);
        params.put("user", pushUser);
        params.put("extra_params", extraParams);
        return params;
    }

    /**
     * @param sId
     * @param sendType    发送类型 0-工单提示信息 7：电子围栏报警 8：实数数据超限报警 9：故障码报警 10：访问
     *                    11：收藏 12：转发 13：申请解锁
     *                    14-车辆工作小时达到保养的工时 15-车辆油位低于x%的时候 16-车辆报出故障代码的时候',
     *                    17-今日工单速报 18-今日车辆速报 19-车辆工作小时达到保养的工时(钻通)
     *                    20-招标信息(某条信息)
     * @param context
     * @param pushUser
     * @param receiveUser
     * @param carId
     * @param orderId
     * @param client
     * @return
     */
    private Map<String, Object> generateMessageRecordParams(String sId, Integer sendType, String title, String context, String pushUser,
                                                            String receiveUser, String carId, String orderId, String client,
                                                            String extraParams) {
        Map<String, Object> params = new HashMap<>();
        params.put("s_id", sId);
        params.put("send_type", sendType);
        params.put("title", title);
        params.put("context", context);
        params.put("push_content", context);
        params.put("push_user_id", receiveUser);
        params.put("receive_user", receiveUser);
        params.put("c_id", carId);
        params.put("order_id", orderId);
        params.put("client", client);
        params.put("is_flag", 1);
        params.put("status", 0);
        params.put("send_grade", null);
        params.put("user", pushUser);
        params.put("extra_params", extraParams);
        return params;
    }

//    @Scheduled(cron = "0 0/2 * * * ?")
    //@Transactional(rollbackFor = Exception.class)
    public void timeOutPushCron() {
        //todo 查询满足条件工单
        List<Map<String, Object>> pushByOrder = orderDao.selectPushByOrder();
        if (pushByOrder.size()==0){
            return;
        }
        //推送超时useLlist
        for(Map<String, Object> item : pushByOrder){
            String orderId = item.get("orderId").toString();
            String orderNo = item.get("order_no").toString();
            String content="";
            String orderEnd = orderNo.substring(orderNo.length() - 4);
            switch (parseInt(item.get("order_status"))) {
                case 2://客服超时
                    if (parseInt(item.get("secondTime")) > parseInt(item.get("kfTime"))) {
                        if(item.get("area")!=null && item.get("o_id") != null){
                            Map<String, Object> byId = userDao.getUserById(item.get("o_id").toString());
                            if(byId != null) {
                                List<Map<String, Object>> area = userDao.getUserByArea(item.get("area").toString(), item.get("s_id").toString());
                                if (area.size() > 0) {
                                    area.forEach(item1 -> {
                                        String content1 = String.format(PushConstants.TEMPLATE_ORDER_NODE_CZ, byId.get("user_name").toString()
                                                , (parseInt(item.get("kfTime"))) / 60);
                                        this.pushOrderBy(item.get("s_id").toString(), content1, item1.get("id").toString()
                                                , orderId, parseInt(item.get("order_status")), 0);
                                    });
                                }
                            }
                        }
                    }
                    break;
                case 3://听诊超时
                    if (parseInt(item.get("secondTime")) > parseInt(item.get("tzTime"))) {
                        Map<String, Object> byId = userDao.getUserById(item.get("u_t_id").toString());
                        content=String.format(PushConstants.TEMPLATE_ORDER_NODE_TZ,byId.get("user_name").toString()
                                ,orderEnd, (parseInt(item.get("tzTime")))/60);
                        this.pushOrderBy(item.get("s_id").toString(),content,item.get("u_t_id").toString()
                                ,orderId,parseInt(item.get("order_status")),0);
                    }
                    break;
//                case 5://仓管超时
//                    if (parseInt(item.get("secondTime")) > parseInt(item.get("cgTime"))) {
//                        content=String.format(PushConstants.TEMPLATE_ORDER_NODE_CG
//                                ,orderEnd, parseInt(item.get("cgTime")));
//                        this.pushOrderBy(item.get("s_id").toString(),content,item.get("u_cg_id").toString()
//                                ,orderId,parseInt(item.get("order_status")),0);
//                    }
//                    break;
                case 6://修工
                    if (parseInt(item.get("secondTime")) > parseInt(item.get("xgTime"))) {
                        List<String> repairManList = cGOrderDao.selectRepairMan(orderId);
                        repairManList.forEach(item1->{
                            Map<String, Object> byId = userDao.getUserById(item1);
                            String content1=String.format(PushConstants.TEMPLATE_ORDER_NODE_XG_RECEIVE,byId.get("user_name").toString()
                                    , orderEnd ,(parseInt(item.get("xgTime")))/60);
                            this.pushOrderBy(item.get("s_id").toString(),content1,item1
                                    ,orderId,parseInt(item.get("order_status")),0);
                        });

                    }
                    break;
                case 9://修工到达
                    if (parseInt(item.get("secondTime")) > parseInt(item.get("xgArriveTime"))) {
                        List<String> repairManList = cGOrderDao.selectRepairMan(orderId);
                        repairManList.forEach(item1->{
                            Map<String, Object> byId = userDao.getUserById(item1);
                            String content1=String.format(PushConstants.TEMPLATE_ORDER_NODE_XG_CONFIRM,byId.get("user_name").toString()
                                    ,orderEnd , (parseInt(item.get("xgArriveTime")))/60);
                            this.pushOrderBy(item.get("s_id").toString(),content1,item1
                                    ,orderId,parseInt(item.get("order_status")),0);
                        });
                    }
                    break;
            }
        };
        //todo 1,2,3级别推送
        this.pushLevel(Constants.PUSH_LEVEL_ONE);
        this.pushLevel(Constants.PUSH_LEVEL_TWO);
        this.pushLevel(Constants.PUSH_LEVEL_THREE);

    }

    public Integer parseInt(Object status) {
        return Integer.parseInt(status.toString());
    }

    public void pushLevel(Integer pushLevel) {
        List<Map<String, Object>> list = orderDao.selectOrderPushLevel(pushLevel);
        //推送超时useLlist
        list.forEach(item -> {
            String content="";
            if (!item.get("pushTime").equals("")){
                String orderId = item.get("orderId").toString();
                String orderNo = item.get("order_no").toString();
                String orderEnd = orderNo.substring(orderNo.length() - 4);
                switch (parseInt(item.get("order_status"))) {
                    case 2://客服超时
                        if (parseInt(item.get("pushTime")) < parseInt(item.get("kfTime"))) {
                            Map<String, Object> byId = userDao.getUserById(item.get("o_id").toString());
                            List<Map<String, Object>> area = userDao.getUserByArea(item.get("area").toString(),item.get("s_id").toString());
                            if (area.size()>0){
                                    String content1=String.format(PushConstants.TEMPLATE_ORDER_NODE_CZ,byId.get("user_name").toString()
                                            , parseInt(item.get("kf_time"))+parseInt(item.get("push_time")));
                                    this.pushOrderBy(item.get("s_id").toString(),content1,item.get("u_id").toString()
                                            ,orderId,parseInt(item.get("order_status")),pushLevel);
                            }

                        }
                        break;
                    case 3://听诊超时
                        if (parseInt(item.get("pushTime")) < parseInt(item.get("tzTime"))) {
                            Map<String, Object> byId = userDao.getUserById(item.get("u_t_id").toString());
                            content=String.format(PushConstants.TEMPLATE_ORDER_NODE_TZ,byId.get("user_name").toString()
                                   ,orderEnd , parseInt(item.get("tz_time"))+parseInt(item.get("push_time")));
                            this.pushOrderBy(item.get("s_id").toString(),content,item.get("u_id").toString()
                                    ,orderId,parseInt(item.get("order_status")),pushLevel);
                        }
                        break;
//                    case 5://仓管超时
//                        if (parseInt(item.get("secondTime")) > parseInt(item.get("cgTime"))) {
//                            content=String.format(PushConstants.TEMPLATE_ORDER_NODE_KF
//                                    ,orderEnd  , parseInt(item.get("cgTime")));
//                            this.pushOrderBy(item.get("s_id").toString(),content,item.get("u_id").toString()
//                                    ,orderId,parseInt(item.get("order_status")),pushLevel);
//                        }
//                        break;
                    case 6://修工
                        if (parseInt(item.get("pushTime")) < parseInt(item.get("xgTime"))) {
                            List<String> repairManList = cGOrderDao.selectRepairMan(orderId);
                            repairManList.forEach(item1->{
                                Map<String, Object> byId = userDao.getUserById(item1);
                                String content1=String.format(PushConstants.TEMPLATE_ORDER_NODE_XG_RECEIVE,byId.get("user_name").toString()
                                        , orderEnd ,parseInt(item.get("xg_time"))+parseInt(item.get("push_time")));
                                this.pushOrderBy(item.get("s_id").toString(),content1,item.get("u_id").toString()
                                        ,orderId,parseInt(item.get("order_status")),pushLevel);
                            });

                        }


                        break;
                    case 9://修工到达
                        if (parseInt(item.get("pushTime")) < parseInt(item.get("xgArriveTime"))) {
                            List<String> repairManList = cGOrderDao.selectRepairMan(orderId);
                            repairManList.forEach(item1->{
                                Map<String, Object> byId = userDao.getUserById(item1);
                                String content1=String.format(PushConstants.TEMPLATE_ORDER_NODE_XG_CONFIRM,byId.get("user_name").toString()
                                        ,orderEnd , parseInt(item.get("xg_arrive_time"))+parseInt(item.get("push_time")));
                                this.pushOrderBy(item.get("s_id").toString(),content1,item.get("u_id").toString()
                                        ,orderId,parseInt(item.get("order_status")),pushLevel);
                            });
                        }
                        break;
                }
            }
        });
    }

    public void pushOrderBy(String sId,String content,String uId,String orderId,Integer status,Integer pushStatus){
        Map<String, Object> extraParamsMap = new HashMap<>();
        extraParamsMap.put("orderId", orderId);
        extraParamsMap.put("orderStatus", status);
        Map<String, Object> messageRecord = this.generateOrderNodeInfoMessageRecord(sId,
                content,uId,orderId, JSON.toJSONString(extraParamsMap));
        Map<String, Object> message = this.pushMessageOrderNodeRemindParams(uId
                , DateUtil.formatTime( LocalDateTime.now()),
                content, sId, orderId, parseInt(status));
        //推送
        jiGuangPushUtil.publishMessagePush(message, PushConstants.KEY_ORDER_ID
                , orderId, messageRecord.get("id").toString());
        //记录
        messageRecordDao.addMessageRecord(messageRecord);
        //更新push_status
        messageRecordDao.updatePushStatus(orderId,pushStatus);
    }

    // 人脸识别的推送--非法点火
    // @Scheduled(cron = "0 0/1 * * * *")
    public void humanfacePush() {

        List<String> humanfaceThingsId = tSSsHumanfaceService.getThingsList();

        humanfaceThingsId.forEach(thingsId -> {

            try {
                Map<String, Object> pcCarMap = toolCarDataMapper.getPcCar(thingsId);

                Map<String, Object> carInfo = toolCarDataMapper.getCarInfo(thingsId);

                Map<String, Object> realCarInfo = toolCarDataMapper.getRealDataThingsId(thingsId);

                String deviceNameStr = "";

                if (carInfo.get("advice_name") != null) {

                    deviceNameStr = carInfo.get("advice_name").toString();
                }

                String adviceTemplateId = pcCarMap.get("device_template").toString();
                String tableName = ThingsData.getTableName(adviceTemplateId);

                Map<String, Object> reqMap = new HashMap<>();

                reqMap.put("tableName",tableName);
                reqMap.put("things_id",thingsId);

                // 获取车辆最新设备信息
                Map<String, Object> carDataMap = tSSsHumanfaceDao.lastCarHumanFaceACC_ERR(reqMap);

                String carStatus = "";

                if (realCarInfo != null) {

                    // 车辆状态
                    carStatus = realCarInfo.get("status").toString();
                }

                if (carDataMap != null && carStatus.equals("1")) {

                    //推送 车辆
                    String pushTime = DateUtil.formatTime(LocalDateTime.now());
                    Map<String, Object> message = this.pushMessageEveryHumanFace("96b601d1637f460a87bc1370bc3afb22",pushTime, "车辆(" + deviceNameStr + ")有未授权人员，尝试启动车辆,请及时查看情况");

                    jiGuangPushUtil.publishMessagePush(message, "", "", "96b601d1637f460a87bc1370bc3afb22");

                    //插入车辆报警表 1非法;2未识别人脸
                    tSSsHumanfaceDao.insertAlarm(thingsId,1);
                }

            } catch (Exception e) {
                logger.error(e.getMessage());
                e.printStackTrace();
            }
        });
    }

    // 人脸识别的推送--30分钟没有识别到人脸
    // @Scheduled(cron = "0 0/10 * * * *")
    public void humanfaceUnauthorizedPush() {

        List<String> humanfaceThingsId = tSSsHumanfaceService.getThingsList();

        humanfaceThingsId.forEach(thingsId -> {

            try {
                Map<String, Object> pcCarMap = toolCarDataMapper.getPcCar(thingsId);

                Map<String, Object> carInfo = toolCarDataMapper.getCarInfo(thingsId);

                String deviceNameStr = "";

                if (carInfo.get("advice_name") != null) {

                    deviceNameStr = carInfo.get("advice_name").toString();
                }

                String adviceTemplateId = pcCarMap.get("device_template").toString();
                String tableName = ThingsData.getTableName(adviceTemplateId);

                Map<String, Object> reqMap = new HashMap<>();

                reqMap.put("tableName",tableName);
                reqMap.put("things_id",thingsId);

                // 获取车辆最新设备信息
                Map<String, Object> humanFaceNum = tSSsHumanfaceDao.lastCarHumanFaceNum(reqMap);

                if (humanFaceNum == null) {

                    //推送 车辆
                    String pushTime = DateUtil.formatTime(LocalDateTime.now());
                    Map<String, Object> message = this.pushMessageEveryHumanFace("96b601d1637f460a87bc1370bc3afb22",pushTime, "车辆(" + deviceNameStr + ")有未授权人员，正在使用车辆,请及时查看情况");

                    jiGuangPushUtil.publishMessagePush(message, "", "", "96b601d1637f460a87bc1370bc3afb22");

                    //插入车辆报警表 1非法;2未识别人脸
                    tSSsHumanfaceDao.insertAlarm(thingsId,2);
                }

            } catch (Exception e) {
                logger.error(e.getMessage());
                e.printStackTrace();
            }
        });
    }

    /**
     * 车辆工作小时达到保养的工时（车主） - 针对用于钻通
     */
    @Scheduled(cron="0 0 0/3 * * ?") // 每3小时执行一次, 定时器的周期设定为3小时(跨过增量时间)
    public void carWorkHoursReachMaintenanceForZT() {
        // 获取车辆到达该保养时间却没保养的所有车辆 - 钻通(钻通正式库的s_id: a892450bd6084f4484a5479e0a9c1b23)
        List<Map<String, Object>> workHoursReachMaintenance = toolCarDataMapper.getWorkHoursReachMaintenanceForZT();
        if (workHoursReachMaintenance.size() > 0) {
            for (Map<String, Object> maintenance : workHoursReachMaintenance) {
                String sId = maintenance.get("s_id").toString();
                // 如果是 ”钻通(a892450bd6084f4484a5479e0a9c1b23)-正式库“ 或 “山多维克(be7bf99ac18a42bdb1f534c85497e227)-测试库”
                if(sId.equals("a892450bd6084f4484a5479e0a9c1b23") || sId.equals("be7bf99ac18a42bdb1f534c85497e227")) {
                    String engineTotalHourString = new BigDecimal(maintenance.get("engineTotalHour").toString()).stripTrailingZeros().toPlainString();
                    double engineTotalHour = Double.parseDouble(engineTotalHourString);

                    boolean needSendFlag = false;
                    String titleStr = "保养";
                    // 需要推送提醒的情况:
                    // 100(首保)、500、1000三个周期进行提醒
                    // 增量为上下 2 , 定时器的周期设定为3小时(跨过增量时间)
                    if(engineTotalHour >= 98 && engineTotalHour < 102) {
                        needSendFlag = true;
                        titleStr = "首保";
                    } else if(engineTotalHour >= 498 && engineTotalHour < 502) {
                        needSendFlag = true;
                    } else if(engineTotalHour >= 998 && engineTotalHour < 1002) {
                        needSendFlag = true;
                    }

                    if(needSendFlag) {
                        String serverName = maintenance.get("serverName").toString();
                        String carId = maintenance.get("car_id").toString();
                        String carType = maintenance.get("car_type").toString();
                        String model = maintenance.get("model").toString();
                        String brand = maintenance.get("brand").toString();
                        String thingsId = maintenance.get("things_id").toString();
                        String owner_id = maintenance.get("owner_id").toString();

                        int count = pushMessageRecordMapper.getPushMessageNotificationCount(maintenance);
                        if (count == 0) {
                            Map<String, Object> messageRecord = this.generateCarMaintenanceForZTMessageRecord(sId, String.format(PushConstants.TEMPLATE_CAR_WORK_REMIND_TITLE_ZT, titleStr),
                                    String.format(PushConstants.TEMPLATE_CAR_WORK_REMIND_ZT, serverName, brand, carType, model, engineTotalHourString, titleStr), owner_id,
                                    carId, this.getExtraParams(PushConstants.KEY_PUSH_CAR_MAINTENANCE_ZT, ""));

                            messageRecordDao.addMessageRecord(messageRecord);

                            // 推送消息并且保存推送信息
                            jiGuangPushUtil.publishMessagePush(messageRecord, PushConstants.KEY_PUSH_CAR_MAINTENANCE_ZT, "", messageRecord.get("id").toString());

                            // 保存推送次数
                            pushMessageRecordMapper.savePushMessageNotificationCount(this.generateCarMaintenanceNotificationRecordParams(thingsId, carId, owner_id));
                        }
                    }
                }
            }
        }
    }

    /**
     * 车辆闲置超过七天进行推送
     */
    //@Scheduled(cron="0 0 10 * * ?")//每天早上10点执行一次
    public void equipmentIdleWarning(){
        //获取所有绑定车主的设备
        List<Map<String,Object>> equipList = toolCarDataMapper.selectAllBindedCar();
        equipList.forEach(item ->{
            //根据things_id获取设备七天的数据
            int result = toolCarDataMapper.selectEquipDataList(item.get("things_id").toString());
            if(result == 0){
                String titleStr = "设备闲置";
                String sId = item.get("s_id").toString();
                String carId = item.get("c_id").toString();
                String carType = item.get("car_type").toString();
                String model = item.get("model").toString();
                String brand = item.get("brand").toString();
                String thingsId = item.get("things_id").toString();
                String owner_id = item.get("o_id").toString();
                Map<String,Object> params = new HashMap<>();
                params.put("things_id",thingsId);
                params.put("owner_id",owner_id);
                String value = JSON.toJSONString(params);
                //七天内没有推送则进行推送
                int count = toolCarDataMapper.selectPushCountInSevenDays(owner_id, thingsId, 101);
                if(count ==0 ) {
                    Map<String, Object> messageRecord = this.generateCarFreeWarningMessageRecord(sId, String.format(PushConstants.TEMPLATE_CAR_FREE_TITLE, titleStr),
                            String.format(PushConstants.TEMPLATE_CAR_FREE, brand, carType, model), owner_id,
                            carId, this.getExtraParams(PushConstants.KEY_PUSH_CAR_FREE_WARNING, value));
                    messageRecordDao.addMessageRecord(messageRecord);
                    jiGuangPushUtil.publishMessagePush(messageRecord, PushConstants.KEY_PUSH_CAR_FREE_WARNING, "", messageRecord.get("id").toString());
                }
            }
        });
    }

    /**
     * 通知栏
     * 每天推送一条APP推广活动的提醒(所有用户)
     */
    @Scheduled(cron = "0 0 9 * * ? ")
    public void everyDayPushAppPromotionActivityTraffic() {
        String pushTime = DateUtil.formatTime(LocalDateTime.now());
        Map<String, Object> message = this.pushMessageAppPromotionActivitytrAfficParams(pushTime, PushConstants.PushAppPromotionActivityTraffic1Content);

        jiGuangPushUtil.publishMessagePushAll(message, PushConstants.KEY_AppPromotion_ActivityTraffic1, "");

        // message.put("push_user_id", "61f7eca3a7cf4eb4a7bf775a11df2045");
        // jiGuangPushUtil.publishMessagePush(message, PushConstants.KEY_AppPromotion_ActivityTraffic1, "");
    }
}